//
//  LPPZSNSNavHeadView.m
//  BeStore
//
//  Created by 范云飞 on 16/12/20.
//  Copyright © 2016年 周小宏. All rights reserved.
//

#import "HWDNavHeadView.h"

@interface HWDNavHeadView()
@end
@implementation HWDNavHeadView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        self.headBgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.headBgView.backgroundColor=[UIColor colorWithHexString:@"#58CAB2"];
//        self.headBgView.image = [UIImage imageNamed:@"nav－-bar"];
        //隐藏黑线
        self.headBgView.alpha=0;
        [self addSubview:self.headBgView];
        
        self.back=[UIButton buttonWithType:UIButtonTypeCustom];
        self.back.backgroundColor=[UIColor clearColor];
        self.back.frame=CGRectMake(5, 20, 44, 44);
        [self.back addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.back];
        
        self.backgroundColor=[UIColor clearColor];
        self.label=[[UILabel alloc]initWithFrame:CGRectMake(44, 20, frame.size.width-44-44, 44)];
        self.label.textAlignment=NSTextAlignmentCenter;
        self.label.font = [UIFont systemFontOfSize:19];
        [self addSubview:self.label];
        
        self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.rightBtn.backgroundColor = [UIColor clearColor];
        self.rightBtn.frame = CGRectMake(self.frame.size.width-46, 30, 30, 30);
        [self.rightBtn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.rightBtn];

        self.activityView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(self.frame.size.width-46, 30, 30, 30)];
        self.activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
        [self addSubview:self.activityView];
        
    }
    return self;
}
-(void)setBackTitleImage:(NSString *)backTitleImage{
    _backTitleImage=backTitleImage;
    [self.back setImage:[UIImage imageNamed:_backTitleImage] forState:UIControlStateNormal];
}
-(void)setRightImageView:(NSString *)rightImageView{
    _rightImageView=rightImageView;
    [self.rightBtn setImage:[UIImage imageNamed:_rightImageView] forState:UIControlStateNormal];
}
-(void)setRightTitleImage:(NSString *)rightImageView{
    _rightImageView=rightImageView;
    [self.rightBtn setImage:[UIImage imageNamed:_rightImageView] forState:UIControlStateNormal];
}

-(void)setTitle:(NSString *)title{
    _title=title;
    self.label.text=title;
    //self.label.textColor=[UIColor whiteColor];
}

-(void)setColor:(UIColor *)color{
    _color=color;
    self.label.textColor=color;
}

//返回按钮
-(void)backClick{
    if ([_delegate respondsToSelector:@selector(NavHeadback)] ) {
        [_delegate NavHeadback];
    }
}
//右边按钮
-(void)rightBtnClick{
    if ([_delegate respondsToSelector:@selector(NavHeadToRight)]) {
        [_delegate NavHeadToRight];
    }
}

@end
